import { Exclude, Transform } from 'class-transformer';
import { Column, Entity } from 'typeorm';
import { CommonEntity } from '../../../common/entities/common.entity';
import { getPublicFileLink } from '../../shared/minio/minio.service';
@Entity({
  name: 'user',
  comment: '用户信息表',
})
export class User extends CommonEntity {
  @Column({
    name: 'username',
    length: 255,
    type: 'varchar',
    comment: '用户名',
  })
  username: string;

  @Column({
    name: 'email',
    length: 255,
    type: 'varchar',
    comment: '邮箱',
  })
  email: string;

  @Exclude()
  @Column({
    name: 'password',
    length: 255,
    type: 'varchar',
    comment: '密码',
  })
  password: string;

  @Transform(({ value }) => getPublicFileLink(value))
  @Column({
    name: 'avatar',
    length: 255,
    type: 'varchar',
    nullable: true,
    comment: '头像文件路径',
  })
  avatar: string;
}
